
import ItemToastModel from "./ItemToastModel";
import BaseView from "../base/view/BaseView";
import ActionHelper from "../action/ActionHelper";
import PoolManager from "../pool/PoolManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ItemToastView extends BaseView {

    @property(cc.Label)
    label: cc.Label = null;

    @property(cc.Sprite)
    icon: cc.Sprite = null;
    @property(cc.SpriteAtlas)
    atlas: cc.SpriteAtlas = null;


    protected model: ItemToastModel;


    onEnable() {
        // super.onEnable();
        // cc.log(' ToastView onEnter ')
        this.label.string = this.model.getContent();
        this.icon.spriteFrame = this.atlas.getSpriteFrame(this.model.getImage())
    }

    play(){
        ActionHelper.toastAction(this.node,()=>{
            this.close();
        });  
    }

    close() {
        this.node.x = 0;
        this.node.y = 0;
        PoolManager.instance().put(this.node,true)
    }


}
